<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

// [ 应用入口文件 ]

// 定义应用目录

define('APP_PATH', __DIR__ . '/../application/');

define('APP_MODULE','api');
require __DIR__ . '/../thinkphp/base.php';

require APP_PATH . '/config/constant.php';
require APP_PATH . '/config/cacheKey.php';
// 通过DotEnv导入配置文件
$configPath = realpath(__DIR__ . '/../application/config');
$configName = file_exists($configPath . '/.env') ? '.env' : '.env.example';
$dotEnv = new \Dotenv\Dotenv($configPath, $configName);
$dotEnv->load();
\think\Loader::addNamespace('common','../common/');



if (isset($_SERVER['HTTP_ORIGIN'])) {
	header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
	header('Access-Control-Allow-Credentials: true');
	header('Access-Control-Max-Age: 86400');    // cache for 1 day
}
 
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
	 
	if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
		header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
	 
	if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
		header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
	 
}
// 添加额外的代码
// ...
// 执行应用
\think\App::run()->send();